Implementing messaging

This messaging scheme may be implemented using any Windows application development environment that supports the Win32 API. Examples are provided, in Visual C++ using MFC and in VB.NET, for download from https://readacard.com/support. The steps involved are described here in more detail to allow other development environments to be used:

To register with Read‑a‑Card:

  1. Find the Read-a-Card window handle. This can be achieved using the win32api.FindWindow function to look for a window with the title Read‑a‑Card.

  2. Create a custom message ID using the win32api.RegisterWindowMessage function with READACARD as the argument.

  3. Use win32api.SendMessage to send a message to the Read‑a‑Card window. The message ID should be the one created in step 2 and the LPARAM should be your application’s window handle. The WPARAM is an 8 bit action mask that tells Read‑a‑Card what actions it should take itself when a card is presented.

    The following is the bitwise representation of the Action Mask:

    X X X X   X X X X

    7 6 5 4   3 2 1 0

    Bit

    Use

    Enable

    Disable

    7

    Not Used

    N/A

    N/A

    6

    Log Action

    0

    1

    5

    URL/HTTP Action

    0

    1

    4

    Command Action

    0

    1

    3

    Sound Action

    0

    1

    2

    Clipboard Action

    0

    1

    1

    Keyboard Action

    0

    1

    0

    Not used

    N/A

    N/A

    For example, a WPARAM of integer value 1 will register with Read‑a‑Card and leave all functions on, while a value of 3 will register with Read‑a‑Card and also turn off the keyboard action.

When registered, your application’s window handler will receive WM_COPYDATA messages from Read‑a‑Card whenever a card is presented.

The lpData member of the received COPYDATASTRUCT object can be interpreted as a pointer to a Read‑a‑Card structure, comprising 4 null‑terminated unicode character arrays each having a maximum length of 256 bytes.

The following shows the C++ structure for this data:

typedef struct {

      WCHAR cardID[256];

      WCHAR readerSerial[256];

      WCHAR cardType[256];

      WCHAR timeStamp[256];

} READ_A_CARD_DATA;

Depending on the development environment of your application, these character arrays may require conversion to be displayed as string types. See the VB.NET sample code for an example of this type of conversion.